package com.example.fengyungo_user.activity.me;

import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.RatingBar;
import android.widget.TextView;
import android.widget.Toast;

import androidx.appcompat.app.AlertDialog;

import com.alibaba.fastjson.JSONObject;
import com.alipay.sdk.app.EnvUtils;
import com.alipay.sdk.app.PayTask;
import com.example.fengyungo_user.R;
import com.example.fengyungo_user.activity.BaseActivity;
import com.example.fengyungo_user.activity.main.MainActivity;
import com.example.fengyungo_user.constant.DriverConstant;
import com.example.fengyungo_user.constant.OrderConstant;
import com.example.fengyungo_user.constant.PayConstant;
import com.example.fengyungo_user.constant.ResultConstant;
import com.example.fengyungo_user.constant.TextConstant;
import com.example.fengyungo_user.constant.UserConstant;
import com.example.fengyungo_user.domain.Driver;
import com.example.fengyungo_user.domain.DriverOrderDTO;
import com.example.fengyungo_user.domain.DriverWithNumber;
import com.example.fengyungo_user.domain.Order;
import com.example.fengyungo_user.domain.OrderCreditDTO;
import com.example.fengyungo_user.domain.OrderDetailsVO;
import com.example.fengyungo_user.utils.ActivityCollector;
import com.example.fengyungo_user.utils.BitmapUtils;
import com.example.fengyungo_user.utils.OkHttpUtils;
import com.example.fengyungo_user.utils.OssUtils;
import com.example.fengyungo_user.utils.ThreadPoolUtil;

import java.io.IOException;
import java.util.Map;

/**
 * 我的订单详情页面
 *
 * @author 徐
 */
public class MyOrderDetailActivity extends BaseActivity {

    private static final String TAG = "MyOrderDetailActivity";

    private static final int SDK_PAY_FLAG = 101;

    private String info;

    private ImageView imageView;

    private TextView beginTv;

    private TextView endTv;

    private TextView priceTv;

    private TextView lengthTv;

    private TextView widthTv;

    private TextView heightTv;

    private TextView weightTv;

    private TextView noteTv;

    private TextView earliestTimeTv;

    private TextView latestTimeTv;

    private TextView orderStatusTv;

    private Button getThingBtn;

    private Button cancelOrderBtn;

    private ImageView backIb;

    private Button selectDriverBtn;

    private ProgressBar progressBar;

    private OrderDetailsVO orderDetailsVO;

    private Context context;

    private RatingBar ratingBar;

    private ImageButton driverIb;

    private Driver driverById;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my_order_detail);

        context = this;

        // 从intent获取数据
        Intent intent = getIntent();
        orderDetailsVO = (OrderDetailsVO) intent.getSerializableExtra(OrderConstant.ORDER_DETAILS_VO);

        initControls();

        // 沙箱测试
        EnvUtils.setEnv(EnvUtils.EnvEnum.SANDBOX);

        getThingBtn = findViewById(R.id.btn_get);
        cancelOrderBtn = findViewById(R.id.btn_cancel);
        selectDriverBtn = findViewById(R.id.btn_select);

        progressBar = findViewById(R.id.progress_bar);

        ratingBar = findViewById(R.id.rating);

        backIb = findViewById(R.id.back);
        driverIb = findViewById(R.id.driver);

        // 设置图片
        setImage();

        // 分情况显示按钮
        // 如果订单状态为：已接单，已送达，显示确认收获按钮
        Log.d(TAG, "onCreate: orderStatus=" + orderDetailsVO.getOrderStatus());
        if (orderDetailsVO.getOrderStatus() == (OrderConstant.HAS_RECEIVED) ||
                orderDetailsVO.getOrderStatus() == (OrderConstant.HAS_ARRIVED)) {
            Log.d(TAG, "onCreate: VISIBLE");
            getThingBtn.setVisibility(View.VISIBLE);
        } else {
            getThingBtn.setVisibility(View.GONE);
        }
        // 如果订单状态为：未接单，显示取消订单按钮，显示选择司机按钮
        if (orderDetailsVO.getOrderStatus().equals(OrderConstant.NO_RECEIVED)) {
            cancelOrderBtn.setVisibility(View.VISIBLE);
            selectDriverBtn.setVisibility(View.VISIBLE);
        } else {
            cancelOrderBtn.setVisibility(View.GONE);
            selectDriverBtn.setVisibility(View.GONE);
        }
        // 如果订单状态为：已收货，显示评分控件
        if (orderDetailsVO.getOrderStatus().equals(OrderConstant.HAS_GOT_GOODS)) {
            ratingBar.setVisibility(View.VISIBLE);
        } else {
            ratingBar.setVisibility(View.GONE);
        }
        // 如果订单状态为：已接单、已送达、已收货，显示司机详情按钮
        if (orderDetailsVO.getOrderStatus().equals(OrderConstant.HAS_RECEIVED)
                || orderDetailsVO.getOrderStatus().equals(OrderConstant.HAS_ARRIVED)
                || orderDetailsVO.getOrderStatus().equals(OrderConstant.HAS_GOT_GOODS)) {
            driverIb.setVisibility(View.VISIBLE);
        } else {
            driverIb.setVisibility(View.GONE);
        }

        // 点击事件
        backIb.setOnClickListener((v) -> {
            finish();
        });
        getThingBtn.setOnClickListener((v) -> {
            // 支付
            if (orderDetailsVO.getPayStatus().equals(OrderConstant.NO_PAID)) {
                payToMall();
            }
            // 支付成功后确认收货
            // 已经支付
            if (orderDetailsVO.getPayStatus().equals(OrderConstant.HAS_PAID)) {
                // 确认收货
                hasGotThing();
            }
            // 确认收货后司机可接受平台转账
            payToDriver();
        });
        cancelOrderBtn.setOnClickListener((v) -> {
            // 取消订单
            // 如果未支付，不需要退款
            if (orderDetailsVO.getPayStatus().equals(OrderConstant.NO_PAID)) {
                cancelOrder();
            } else {
                cancelOrder();
                refund();
            }
        });
        selectDriverBtn.setOnClickListener((v) -> {
            // 跳转到选择司机页面
            Intent intent2 = new Intent(this, SelectDriverActivity.class);
            intent2.putExtra(OrderConstant.NUMBER, orderDetailsVO.getNumber());
            intent2.putExtra(OrderConstant.BEGIN, orderDetailsVO.getBegin());
            intent2.putExtra(OrderConstant.END, orderDetailsVO.getEnd());
            startActivity(intent2);
        });
        driverIb.setOnClickListener((v) -> {
            // 跳转到司机详情页
            Driver driver = getDriver();
            DriverWithNumber driverWithNumber = new DriverWithNumber();

            driverWithNumber.setNickname(driver.getNickname());
            driverWithNumber.setAvatar(driver.getAvatar());
            driverWithNumber.setMail(driver.getMail());
            driverWithNumber.setPhone(driver.getPhone());
            driverWithNumber.setSex(driver.getSex());
            driverWithNumber.setCredit(driver.getCredit());

            Intent intent3 = new Intent(this, DriverDetailActivity.class);
            intent3.putExtra(DriverConstant.DRIVER, driverWithNumber);
            intent3.putExtra(DriverConstant.KEY_FOR_DRIVER_DETAIL, DriverConstant.NOT_SELECT);
            startActivity(intent3);
        });

        // 评分
        // 设置为指示器，无法交互
        ratingBar.setIsIndicator(true);
        // 设置评分
        ratingBar.setRating(orderDetailsVO.getCredit());
        FrameLayout frameLayout = findViewById(R.id.frame_layout);
        frameLayout.setOnClickListener((v) -> {
            Log.d(TAG, "onCreate: click rattingBar");
            new AlertDialog.Builder(this)
                    .setTitle(R.string.edit_credit)
                    .setMessage(R.string.do_you_want_edit_credit)
                    .setPositiveButton(R.string.ok, (dialogInterface, i) -> {
                        // 设置不为指示器，可交互
                        ratingBar.setIsIndicator(false);
                    })
                    .setNegativeButton(R.string.cancel, (dialogInterface, i) -> {
                    })
                    .show();
        });
        // 一下只能设置一次评分
        ratingBar.setOnRatingBarChangeListener((ratingBar, rating, fromUser) -> {
            progressBar.setVisibility(View.VISIBLE);
            // 设置为指示器，无法交互
            ratingBar.setIsIndicator(true);
            // 提交评分
            setCredit(rating);
        });
    }

    /**
     * 设置图片
     */
    private void setImage() {
        // 从SharedPreferences中获取图片
        Bitmap bitmapFromSp = BitmapUtils.getBitmapFromSharedPreferences(this, orderDetailsVO.getNumber());
        Log.d(TAG, "setImage: bitmapFromSp=" + bitmapFromSp);
        if (bitmapFromSp == null) {
            // 从oss获取图片并存到sp中
            saveImageToSharedPreferences();
        }
        imageView.setImageBitmap(bitmapFromSp);
    }

    /**
     * 将图像存SharedPreference中
     */
    private void saveImageToSharedPreferences() {
        Runnable runnable = () -> {
            String orderImageUrl = orderDetailsVO.getImage();
            Bitmap bitmapFromOss = null;
            if (OkHttpUtils.isValidUrl(orderImageUrl)) {
                bitmapFromOss = OssUtils.getBitmapFromOss(this, orderImageUrl);
            } else {
                Log.d(TAG, "saveImageToSharedPreferences: notInvalidUrl");
            }
            Log.d(TAG, "saveImageToSharedPreferences: bitmapFromOss=" + bitmapFromOss);
            if (bitmapFromOss == null) {
                bitmapFromOss = BitmapFactory.decodeResource(getResources(), R.drawable.image);
            } else {
                BitmapUtils.saveBitmapToSharedPreferences(bitmapFromOss, this, orderDetailsVO.getNumber());
            }
            Bitmap finalBitmapFromOss = bitmapFromOss;
            runOnUiThread(() -> {
                imageView.setImageBitmap(finalBitmapFromOss);
            });
        };
        ThreadPoolUtil.execute(runnable);
    }

    /**
     * 设置评分
     */
    private void setCredit(float rating) {
        OrderCreditDTO orderCreditDTO = new OrderCreditDTO();
        // 评分
        orderCreditDTO.setCredit(rating);
        // 订单编号
        orderCreditDTO.setNumber(orderDetailsVO.getNumber());
        // 司机id
        orderCreditDTO.setReceiverId(orderDetailsVO.getReceiverId());
        String json = JSONObject.toJSONString(orderCreditDTO);
        Runnable runnable = () -> {
            String url = UserConstant.URL_USER_USER + "/credit";
            try {
                String responseData = OkHttpUtils.put(url, json);
                JSONObject jsonObject = JSONObject.parseObject(responseData);
                int code = jsonObject.getInteger(ResultConstant.CODE);
                String msg = jsonObject.getString(ResultConstant.MSG);
                if (code == ResultConstant.SUCCESS) {
                    runOnUiThread(() -> {
                        Toast.makeText(context, TextConstant.ORDER_CREDIT_EDIT_SUCCESS, Toast.LENGTH_SHORT).show();
                        progressBar.setVisibility(View.GONE);
                    });
                } else {
                    runOnUiThread(() -> {
                        Toast.makeText(context, msg, Toast.LENGTH_SHORT).show();
                        progressBar.setVisibility(View.GONE);
                    });
                }
            } catch (IOException e) {
                e.printStackTrace();
                runOnUiThread(() -> {
                    Toast.makeText(context, TextConstant.INTERNET_ERROR, Toast.LENGTH_SHORT).show();
                    progressBar.setVisibility(View.GONE);
                });
            }
        };
        ThreadPoolUtil.execute(runnable);
    }

    /**
     * 平台向司机转账
     */
    private void payToDriver() {
        DriverOrderDTO driverOrderDTO = new DriverOrderDTO();
        driverOrderDTO.setId(orderDetailsVO.getReceiverId());
        driverOrderDTO.setNumber(orderDetailsVO.getNumber());
        driverOrderDTO.setPrice(orderDetailsVO.getPrice());
        String json = JSONObject.toJSONString(driverOrderDTO);
        Runnable runnable = () -> {
            String url = UserConstant.URL_USER_ALIPAY + "/driver";
            try {
                String responseData = OkHttpUtils.post(url, json);
                JSONObject jsonObject = JSONObject.parseObject(responseData);
                int code = jsonObject.getInteger(ResultConstant.CODE);
                String msg = jsonObject.getString(ResultConstant.MSG);
                if (code == ResultConstant.SUCCESS) {
                } else {
                    runOnUiThread(() -> {
                        Toast.makeText(context, msg, Toast.LENGTH_SHORT).show();
                    });
                }
            } catch (IOException e) {
                e.printStackTrace();
                runOnUiThread(() -> {
                    Toast.makeText(context, TextConstant.INTERNET_ERROR, Toast.LENGTH_SHORT).show();
                });
            }
        };
        ThreadPoolUtil.execute(runnable);
    }

    /**
     * 退款
     */
    private void refund() {
        Order order = new Order();
        order.setNumber(orderDetailsVO.getNumber());
        order.setPrice(orderDetailsVO.getPrice());
        String json = JSONObject.toJSONString(order);

        Runnable runnable = () -> {
            String url = UserConstant.URL_USER_ALIPAY + "/refund";
            try {
                String responseData = OkHttpUtils.post(url, json);
                JSONObject jsonObject = JSONObject.parseObject(responseData);
                Log.d(TAG, "refund: responseData=" + responseData);
                int code = jsonObject.getInteger(ResultConstant.CODE);
                String msg = jsonObject.getString(ResultConstant.MSG);
                if (code == ResultConstant.SUCCESS) {
                    runOnUiThread(() -> {
                        Toast.makeText(context, PayConstant.REFUND_SUCCESS_STRING, Toast.LENGTH_SHORT).show();
                    });
                } else {
                    runOnUiThread(() -> {
                        Toast.makeText(context, msg, Toast.LENGTH_SHORT).show();
                    });
                }
            } catch (IOException e) {
                e.printStackTrace();
                runOnUiThread(() -> {
                    Toast.makeText(context, TextConstant.INTERNET_ERROR, Toast.LENGTH_SHORT).show();
                });
            }
        };
        ThreadPoolUtil.execute(runnable);
    }

    /**
     * 取消订单
     */
    private void cancelOrder() {
        progressBar.setVisibility(View.VISIBLE);
        String url = UserConstant.URL_USER_USER + "/cancelOrder/" + orderDetailsVO.getNumber();
        Runnable runnable = () -> {
            try {
                String responseData = OkHttpUtils.put(url, "");
                JSONObject jsonObject = JSONObject.parseObject(responseData);
                int code = jsonObject.getInteger(ResultConstant.CODE);
                String msg = jsonObject.getString(ResultConstant.MSG);
                if (code == ResultConstant.SUCCESS) {
                    runOnUiThread(() -> {
                        progressBar.setVisibility(View.GONE);
                        Toast.makeText(context, OrderConstant.CANCEL_ORDER_STRING, Toast.LENGTH_SHORT).show();
                        // 修改显示的订单状态
                        orderStatusTv.setText(OrderConstant.STATUS_TEXT[OrderConstant.CANCEL_ORDER_FINISHED]);
                    });
                } else {
                    runOnUiThread(() -> {
                        progressBar.setVisibility(View.GONE);
                        Toast.makeText(context, msg, Toast.LENGTH_SHORT).show();
                    });
                }
            } catch (IOException e) {
                e.printStackTrace();
                runOnUiThread(() -> {
                    progressBar.setVisibility(View.GONE);
                    Toast.makeText(context, TextConstant.INTERNET_ERROR, Toast.LENGTH_SHORT).show();
                });
            }
        };
        ThreadPoolUtil.execute(runnable);
    }


    /**
     * 确认收货
     */
    private void hasGotThing() {
        progressBar.setVisibility(View.VISIBLE);
        String url = UserConstant.URL_USER_USER + "/gotGoods/" + orderDetailsVO.getNumber();
        Runnable runnable = () -> {
            try {
                String responseData = OkHttpUtils.put(url, "");
                Log.d(TAG, "hasGotThing: responseData=" + responseData);
                JSONObject jsonObject = JSONObject.parseObject(responseData);
                int code = jsonObject.getInteger(ResultConstant.CODE);
                String msg = jsonObject.getString(ResultConstant.MSG);
                if (code == ResultConstant.SUCCESS) {
                    runOnUiThread(() -> {
                        progressBar.setVisibility(View.GONE);
                        Toast.makeText(context, OrderConstant.HAS_GOT_GOODS_STRING, Toast.LENGTH_SHORT).show();
                        // 修改显示的订单状态
                        orderStatusTv.setText(OrderConstant.STATUS_TEXT[OrderConstant.HAS_GOT_GOODS]);
                        Toast.makeText(context, OrderConstant.PLEASE_SET_CREDIT, Toast.LENGTH_SHORT).show();
                        ActivityCollector.finishOtherActivity(MainActivity.class);
                    });
                } else {
                    runOnUiThread(() -> {
                        progressBar.setVisibility(View.GONE);
                        Toast.makeText(context, msg, Toast.LENGTH_SHORT).show();
                    });
                }
            } catch (IOException e) {
                e.printStackTrace();
                runOnUiThread(() -> {
                    progressBar.setVisibility(View.GONE);
                    Toast.makeText(context, TextConstant.INTERNET_ERROR, Toast.LENGTH_SHORT).show();
                });
            }
        };
        ThreadPoolUtil.execute(runnable);
    }

    /**
     * 初始化控件
     */
    private void initControls() {
        imageView = findViewById(R.id.image);
        beginTv = findViewById(R.id.tv_begin);
        endTv = findViewById(R.id.tv_end);
        priceTv = findViewById(R.id.tv_price);
        lengthTv = findViewById(R.id.tv_length);
        widthTv = findViewById(R.id.tv_width);
        heightTv = findViewById(R.id.tv_height);
        weightTv = findViewById(R.id.tv_weight);
        noteTv = findViewById(R.id.tv_note);
        earliestTimeTv = findViewById(R.id.tv_earliest_time);
        latestTimeTv = findViewById(R.id.tv_latest_time);
        orderStatusTv = findViewById(R.id.tv_order_status);

        getThingBtn = findViewById(R.id.btn_pay_later);
        cancelOrderBtn = findViewById(R.id.btn_pay_now);

        progressBar = findViewById(R.id.progress_bar);

        imageView = findViewById(R.id.image);

        // 修改显示
        beginTv.setText(orderDetailsVO.getBegin());
        endTv.setText(orderDetailsVO.getEnd());
        priceTv.setText(String.valueOf(orderDetailsVO.getPrice()));
        lengthTv.setText(String.format("%s%s", orderDetailsVO.getLength(), OrderConstant.CM));
        widthTv.setText(String.format("%s%s", orderDetailsVO.getWidth(), OrderConstant.CM));
        heightTv.setText(String.format("%s%s", orderDetailsVO.getHeight(), OrderConstant.CM));
        weightTv.setText(String.format("%s%s", orderDetailsVO.getWeight(), OrderConstant.G));
        noteTv.setText(orderDetailsVO.getNote());
        latestTimeTv.setText(orderDetailsVO.getLatestTime());
        earliestTimeTv.setText(orderDetailsVO.getEarliestTime());
        orderStatusTv.setText(OrderConstant.STATUS_TEXT[orderDetailsVO.getOrderStatus()]);
    }

    /**
     * 发送Order到后端，从后端获取orderStr
     *
     * @param order Order
     * @return String
     */
    private String getOrderStr(Order order) {
        info = null;
        Runnable runnable = () -> {
            String jsonString = JSONObject.toJSONString(order);
            try {
                String responseData = OkHttpUtils.post(UserConstant.URL_USER_ALIPAY, jsonString);
                JSONObject jsonObject = JSONObject.parseObject(responseData);
                int code = jsonObject.getInteger(ResultConstant.CODE);
                String msg = jsonObject.getString(ResultConstant.MSG);
                String data = jsonObject.getString(ResultConstant.DATA);
                Log.d(TAG, "getOrderStr: data=" + data);
                if (code == ResultConstant.SUCCESS) {
                    info = data;
                } else {
                    runOnUiThread(() -> {
                        Toast.makeText(context, msg, Toast.LENGTH_SHORT).show();
                        info = TextConstant.ERROR;
                    });
                }
            } catch (IOException e) {
                e.printStackTrace();
                runOnUiThread(() -> {
                    Toast.makeText(context, TextConstant.INTERNET_ERROR, Toast.LENGTH_SHORT).show();
                    info = TextConstant.ERROR;
                });
            }
        };
        ThreadPoolUtil.execute(runnable);
        while (info == null) {
        }
        return info;
    }

    /**
     * 向商家付款
     */
    private void payToMall() {
        // 订单
        Order order = new Order();
        order.setBegin(orderDetailsVO.getBegin());
        order.setEnd(orderDetailsVO.getEnd());
        order.setPrice(orderDetailsVO.getPrice());
        order.setNumber(orderDetailsVO.getNumber());
        // 订单信息
        String orderInfo = getOrderStr(order);
        Log.d(TAG, "payToMall: orderInfo=" + orderInfo);
        Runnable payRunnable = () -> {
            PayTask alipay = new PayTask(this);
            Map<String, String> result = alipay.payV2(orderInfo, true);
            Message msg = new Message();
            Log.d(TAG, "payToMall: result=" + result);
            msg.what = SDK_PAY_FLAG;
            msg.obj = result;
            mHandler.sendMessage(msg);
        };
        // 必须异步调用
        ThreadPoolUtil.execute(payRunnable);
    }

    /**
     * 支付后点击完成或取消支付执行
     */
    private Handler mHandler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            Map<String, String> result = (Map<String, String>) msg.obj;
            String resultStatus = result.get(PayConstant.RESULT_STATUS);
            String memo = result.get(PayConstant.MEMO);
            // 支付成功
            if (resultStatus.equals(PayConstant.PAY_SUCCESS)) {
                // 确认收货
                hasGotThing();
                // 修改状态为已支付
                hasPaid();
                // 跳转到主页
                ActivityCollector.finishOtherActivity(MainActivity.class);
            } else {
                // 支付失败
                Toast.makeText(context, memo, Toast.LENGTH_SHORT).show();
            }
            Log.d(TAG, "handleMessage: " + result);
        }
    };

    /**
     * 修改状态为已支付
     */
    private void hasPaid() {
        String url = UserConstant.URL_USER_USER + "/hasPaid/" + orderDetailsVO.getNumber();
        Runnable runnable = () -> {
            try {
                String responseData = OkHttpUtils.put(url, "");
                JSONObject jsonObject = JSONObject.parseObject(responseData);
                int code = jsonObject.getInteger(ResultConstant.CODE);
                String msg = jsonObject.getString(ResultConstant.MSG);
                if (code == ResultConstant.SUCCESS) {
                } else {
                    runOnUiThread(() -> {
                        Toast.makeText(context, msg, Toast.LENGTH_SHORT).show();
                    });
                }
            } catch (IOException e) {
                e.printStackTrace();
                runOnUiThread(() -> {
                    Toast.makeText(context, TextConstant.INTERNET_ERROR, Toast.LENGTH_SHORT).show();
                });
            }
        };
        ThreadPoolUtil.execute(runnable);
    }

    /**
     * 获取司机信息
     *
     * @return Driver
     */
    private Driver getDriver() {
        String url = UserConstant.URL_USER_USER + "/driver/" + orderDetailsVO.getReceiverId();
        driverById = null;
        Runnable runnable = () -> {
            try {
                String responseData = OkHttpUtils.get(url);
                JSONObject jsonObject = JSONObject.parseObject(responseData);
                int code = jsonObject.getInteger(ResultConstant.CODE);
                String msg = jsonObject.getString(ResultConstant.MSG);
                String data = jsonObject.getString(ResultConstant.DATA);
                if (code == ResultConstant.SUCCESS) {
                    driverById = JSONObject.parseObject(data, Driver.class);
                } else {
                    runOnUiThread(() -> {
                        Toast.makeText(context, msg, Toast.LENGTH_SHORT).show();
                    });
                }
            } catch (IOException e) {
                e.printStackTrace();
                runOnUiThread(() -> {
                    Toast.makeText(context, TextConstant.INTERNET_ERROR, Toast.LENGTH_SHORT).show();
                });
            }
        };
        ThreadPoolUtil.execute(runnable);
        while (driverById == null) {
        }
        return driverById;
    }
}